
#ifndef LOGINWIDGET_H
#define LOGINWIDGET_H

#include <BLabel>
#include <BLineEdit>
#include <BButton>
#include <BBuffer>
#include <BTcpSocket>
#include <BProgressBar>
#include <BTextEdit>
#include <BDialog>

using namespace BWE;

class LoginDialog : public BDialog
{
	BOBJECT(LoginDialog);
public:
	LoginDialog(BWidget* parent = 0);
	~LoginDialog();

	void setSocket(BTcpSocket* socket);
	BTcpSocket* socket() const;

protected:
	void replyLogin(const BBuffer& buffer);
	void replyLogout(const BBuffer& buffer);

protected:
	void slotUsernameOrPasswordEdited();
	void slotLoginClicked(BObject* object, const BValue& value);
	void slotQuitClicked(BObject* object, const BValue& vlalue);

	void slotConnected(BObject* object, const BValue& value);
	void slotReadyRead(BObject* object, const BValue& vlalue);
	void slotDisConnected(BObject* object, const BValue& value);

protected:
	virtual void showEvent(const BEvent& event);
	virtual void hideEvent(const BEvent& event);

	virtual void updateEvent(const BEvent& event);

	virtual void styleEvent(const BEvent& event);
	virtual void paintEvent(const BEvent& event);
	virtual void dragDropEvent(const BMouseEvent& mouseEvent);

private:
	BLabel*					_logoLabel;
	BLineEdit*					_usernameEdit;
	BLineEdit*					_passwordEdit;
	BButton*				_loginButton;
	BButton*				_quitButton;

	BString					_worldName;
	BTcpSocketHolder		_socket;
	BBuffer					_buffer;
};

#endif